package com.vertexnet.realestatenet.model.bean;

// Generated Jun 16, 2012 3:34:15 PM by Hibernate Tools 3.4.0.CR1

import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.CascadeType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

/**
 * Customer generated by hbm2java
 */
@Entity
@Table(name = "customer", catalog = "real_estate_net", uniqueConstraints = @UniqueConstraint(columnNames = "membership_id"))
public class Customer implements java.io.Serializable {
	
	private static final long serialVersionUID = 1L;
	private Integer customerId;
	private Area area;
	private int membershipId;
	private String address;
	private String emailId;
	private String fatherName;
	private String firstName;
	private String lastName;
	private String mobile;
	private String phone;
	private Set<Site> sites = new HashSet<Site>(0);
	private Photo photo;
	private Application application;

	public Customer() {
	}

	public Customer(int membershipId, String firstName, String lastName, String phone) {
		this.membershipId = membershipId;
		this.firstName = firstName;
		this.lastName = lastName;
		this.phone = phone;
	}

	public Customer(Area area, int membershipId, String address, String emailId, String fatherName, String firstName, String lastName, String mobile,
			String phone, Set<Site> sites, Photo photo, Application application) {
		this.area = area;
		this.membershipId = membershipId;
		this.address = address;
		this.emailId = emailId;
		this.fatherName = fatherName;
		this.firstName = firstName;
		this.lastName = lastName;
		this.mobile = mobile;
		this.phone = phone;
		this.sites = sites;
		this.photo = photo;
		this.application = application;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "customer_id", unique = true, nullable = false)
	public Integer getCustomerId() {
		return this.customerId;
	}

	public void setCustomerId(Integer customerId) {
		this.customerId = customerId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "area_id")
	public Area getArea() {
		return this.area;
	}

	public void setArea(Area area) {
		this.area = area;
	}

	@Column(name = "membership_id", unique = true, nullable = false)
	public int getMembershipId() {
		return this.membershipId;
	}

	public void setMembershipId(int membershipId) {
		this.membershipId = membershipId;
	}

	@Column(name = "address")
	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "email_id", length = 25)
	public String getEmailId() {
		return this.emailId;
	}

	public void setEmailId(String emailId) {
		this.emailId = emailId;
	}

	@Column(name = "father_name", length = 25)
	public String getFatherName() {
		return this.fatherName;
	}

	public void setFatherName(String fatherName) {
		this.fatherName = fatherName;
	}

	@Column(name = "first_name", nullable = false, length = 25)
	public String getFirstName() {
		return this.firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	@Column(name = "last_name", nullable = false, length = 25)
	public String getLastName() {
		return this.lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	@Column(name = "mobile", length = 12)
	public String getMobile() {
		return this.mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	@Column(name = "phone", nullable = false, length = 12)
	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "customer", orphanRemoval=true)
	@NotFound(action = NotFoundAction.IGNORE)
	public Set<Site> getSites() {
		return this.sites;
	}

	public void setSites(Set<Site> sites) {
		this.sites = sites;
	}

	@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "customer", orphanRemoval=true)
	@NotFound(action = NotFoundAction.IGNORE)
	public Photo getPhoto() {
		return this.photo;
	}

	public void setPhoto(Photo photo) {
		this.photo = photo;
	}

	@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "customer", orphanRemoval=true)
	@NotFound(action = NotFoundAction.IGNORE)
	public Application getApplication() {
		return this.application;
	}

	public void setApplication(Application application) {
		this.application = application;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Customer) {
			Customer customer = (Customer) obj;
			return new EqualsBuilder().append(this.getCustomerId(), customer.getCustomerId()).isEquals();
		}
		return false;
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(this.getCustomerId()).toHashCode();
	}
}
